﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Finacial
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        FinacialEvent newEvent = new FinacialEvent();
        ObservableCollection<FinacialEvent> evts = null;

        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += MainWindow_Loaded;
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var p = new Person { ID = 0, Name = "Format" };
            evts = new ObservableCollection<FinacialEvent>
            {
                new FinacialEvent { ID = 0, Name = "Pay for Iphone", Amount = 4200, Object = p }
            };

            this.treeView.ItemsSource = evts;
            this.panel.DataContext = newEvent;
        }


        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(newEvent.Name))
            {
                return;
            }

            evts.Add(newEvent);
            panel.DataContext = newEvent = new FinacialEvent();
        }
    }
}
